<?php

namespace app\common\model;

use EasyWeChat\Factory;
use think\Exception;
use think\Model;

/**
 * 邮箱验证码
 */
class ProblemModel extends Model
{
    protected $autoWriteTimestamp = true;
    protected $name = 'problem';


    public function user()
    {
        return $this->belongsTo(StaffModel::class, 'uid', 'id')
            ->field('nickname')->setEagerlyType(0);
    }


    public function problem($params)
    {
        $model = (new self());
        $model->uid = $params['uid'];
        $model->content = $params['content'];

        if ($model->save()) {
            return ['code' => 200, 'msg' => '提交成功'];
        }

        return ['code' => 201, 'msg' => '提交失败'];
    }

    public function loginOut(){
        $data = (new StaffModel())->loginOut($this->request_array);
        $data['code'] == 200 ? $this->success($data['msg'],$data['data']) : $this->error($data['msg']);
    }




}
